<?php
error_reporting(0);
$isadmin=1;    
include '../../comm/config.php';
include '../check.php';
include('../../comm/class_db.php');
$id=$_GET['id'];
$mall = sel_sql("mall", "*", "id=$id");
$mall['catid']?$mall['catid']:1000;
$sql="select * from ".$BIAOTOU."malltype  order by sort asc";
$malltype = mysql_query($sql);
$mall['lm']=$mall['lm']?$mall['lm']:'chanet';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="../css/style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="../../js/calendar/calendar-blue.css"/>
<style>
.tuan{ display:none}
</style>
<script language="javascript" type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript" src="../../js/calendar/calendar.js"></script>
<script charset="utf-8" src="../../kindeditor/kindeditor.js"></script>
<script>
$(function() {
	var editor = KindEditor.create('#content');
});
</script>
<script language="javascript" type="text/javascript">	
function openpic(url,name,w,h)
{
    window.open(url,name,"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}

/*$(function(){
    $('#form1').submit(function(){
		var subm=1;
	    $('.required').each(function(){
		    if($(this).val()==''){
			    $(this).focus().addClass('redborder');
				alert('该字段不能为空');
				subm=0;
				return false;
			}
		});
		if(subm==0) return false;
		if(subm==1) return true;
	});
	$('.required').blur(function(){
	    if($(this).val()!=''){
		    $(this).removeClass('redborder')
		}
	});
});*/
function openwinx(url,name,w,h)
{
	api_city=$('#api_city').val();
	id=$('#id').val();
	if(api_city==''){
	    alert('城市api连接不能为空');
	}
	else if(id==''){
	    alert('保存商城后从新打开再生成城市api');
	}
	else{
	    window.open(url,name,"top=100,left=400,width=" + w + ",height=" + h + ",toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
	}
}


function b(){
    $('.duomai_tr').hide();
    $('.yiqifa_tr').hide();
	$('.linktech_tr').hide();
}

function c(lm){
    b();
	if(lm=='yiqifa'){
	    $('.yiqifa_tr').show();
	}
	if(lm=='duomai'){
	    $('.duomai_tr').show();
	}
	if(lm=='linktech'){
		$('.linktech_tr').show();
	}
}

$(function(){
	var lm = $('#lm').val();
	var cat = $('#cat').find("option:selected").text();
	if(cat.indexOf("团购")>=0){
		$('.tuan').show();
	}
	c(lm);
    $('#lm').change(function(){
	    var lm = $(this).val();
		c(lm);
	});
	$('#cat').change(function(){
	    cat=$(this).find("option:selected").text();
		if(cat.indexOf("团购")>=0){
		    $('.tuan').show();
		}
		else{
		    $('.tuan').hide();
		}
	});
});
pattern = /&c=(\d+)/;
function tSubmit(form){
	var lm = $('#lm').val();
	if(form.name.value==''){
		alert('请填写商城名！');
		form.name.focus();
		return false;
	}
	if(form.fan.value==''){
		alert('请填写最高返现额度！');
		form.fan.focus();
		return false;
	}
	if(form.logo.value==''){
		alert('请上传商城logo！');
		form.logo.focus();
		return false;
	}
	if(form.url.value==''){
		alert('请填写商城官网！');
		form.url.focus();
		return false;
	}
	if(lm=='linktech'){
	    if(form.merchant.value==''){
		    alert('请填写广告主账号！');
		    form.merchant.focus();
		    return false;
	    }
	}
	else if(lm=='yiqifa'){
	    if(form.yilink.value==''){
		    alert('请填写推广链接！');
		    form.yilink.focus();
		    return false;
	    }
        var a= form.yilink.value.match(pattern);
        if(a[1]>0){
		    form.yiqifaid.value=a[1];
		}
		if(form.yiqifaid.value=='' || form.yiqifaid.value==0){
		    alert('请填写亿起发广告id！');
		    form.yiqifaid.focus();
		    return false;
	    }
	}
	else if(lm=='duomai'){
	    if(form.duomaiid.value=='' || form.duomaiid.value==0){
		    alert('请填写多麦广告id！');
		    form.duomaiid.focus();
		    return false;
	    }
	}
	return true;
}
</script>
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td height="30" colspan="2" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="../images/arrow.gif" width="16" height="22" align="absmiddle" /> 添加新的商城</strong></td>
            </tr>
            <tr>
              <td width="100%" colspan="2" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><form id="form1" name="form1" method="post" action="mallsave.php" onsubmit="return tSubmit(this);">
                    <table width="100%"  align="center" border=1 cellpadding=0 cellspacing=0 style="border-collapse: collapse" bordercolor="#dddddd">
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">商城类别：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<select id="cat" name="info[catid]">
                         <?php
						 while ($row = mysql_fetch_array($malltype))
						 {
						 	if($mall['catid']==$row['typecode']){
								$isselected=" selected";
							}else{
								$isselected="";
							}
						 	echo "<option value=".$row['typecode']."".$isselected.">".$row['typename']."</option>";
						 }
						 ?>
                        </select>
                        </td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">所属联盟：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<select name="info[lm]" id="lm">
                        <!--<option <?php if($mall['lm']=='chanet'){?> selected="selected" <?php }?> value="chanet">成果</option>-->
                        <option <?php if($mall['lm']=='duomai'){?> selected="selected" <?php }?> value="duomai">多麦</option>
                        <option <?php if($mall['lm']=='yiqifa'){?> selected="selected" <?php }?> value="yiqifa">亿起发</option>
                        <option <?php if($mall['lm']=='linktech'){?> selected="selected" <?php }?> value="linktech">领客特</option>
                        </select>
                        </td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">商城名：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[name]" type="text" value="<?=$mall['name']?>"  style="width:150px" id="name" /> <span style="color:#999; font-size:12px">不宜过长</span></td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">商城官网：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[url]" type="text" size="60" id="url" value="<?=$mall['url']?>" style="width:150px"/> <span style="color:#999; font-size:12px">商城首页网址</span></td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">最高返：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[fan]" type="text" style="width:45px"  id="fan" value="<?=$mall['fan']?>"/> <span style="color:#999; font-size:12px">只是显示给会员看，不参与具体计算</span></td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">排序：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[sort]" type="text"  style="width:40px"  id="sort" value="<?=$mall['sort']?>"/> <span style="color:#999; font-size:12px">数字越大越靠前</span></td>
                      </tr>
                      <!--<tr>
                        <td width="196" height="30" align="right" class="bigtext">成果广告主id：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[chanetid]" type="text" value="<?=$mall['chanetid']?>" style="width:150px" id="chanetid" /> <span style="color:#999; font-size:12px">如选择成果网，此项必填</span></td>
                      </tr>-->
                      <tr class="duomai_tr">
                        <td width="196" height="30" align="right" class="bigtext">多麦广告主id：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[duomaiid]" type="text" value="<?=$mall['duomaiid']?>" style="width:150px" id="duomaiid" /> <span style="color:#999; font-size:12px">如选择多麦网，此项必填</span></td>
                      </tr>
                      
                      <tr class="yiqifa_tr">
                        <td width="196" height="30" align="right" class="bigtext">亿起发推广网址：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input onblur="var a= this.value.match(pattern);if(a[1]>0){form.yiqifaid.value=a[1];}"  name="info[yilink]" type="text" size="60" id="yilink" value="<?=$mall['yilink']?>" /> <span style="color:#999; font-size:12px">如选择亿起发网，此项必填</span> </td>
                      </tr>
                      <tr class="yiqifa_tr">
                        <td width="196" height="30" align="right" class="bigtext">亿起发广告主id：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[yiqifaid]" type="text" value="<?=$mall['yiqifaid']?>" style="width:150px" id="yiqifaid" /> <input type="button" value="提取广告id" onclick="var a= $('#yilink').val().match(pattern);if(a[1]>0){$('#yiqifaid').val(a[1]);}" style="cursor:pointer" /></td>
                      </tr>
                      <tr class="linktech_tr">
                        <td width="196" height="30" align="right" class="bigtext">领客特广告主账号：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[merchant]" type="text" value="<?=$mall['merchant']?>" style="width:150px" id="merchant" /> <span style="color:#999; font-size:12px">如选择领客特网，此项必填</span></td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">商城logo：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[logo]" id="logo" type="text" class="required" style="width:190px" value="<?=$mall['logo']?>" /><input type="button" value="上传图片" onclick="javascript:openpic('../upload_pic.php?uploadtext=logo&sid=<?=session_id()?>','upload','450','350')" /> <span style="color:#999; font-size:12px">可直接黏贴图片远程地址</span></td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">简介：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[des]" type="text" size="60" id="des" value="<?=$mall['des']?>"/></td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">功能：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;《<a style=" color:#00F;" href="../activity/admin.php?act=addedi&mallid=<?=$mall['id']?>">添加活动</a>》《<a style=" color:#00F;" href="../activity/admin.php?act=list&mallid=<?=$mall['id']?>">查看活动</a>》《<a style=" color:#00F;" href="../mall/mall_comment.php?mallid=<?=$mall['id']?>">查看评论</a>》</td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">服务：</td>
                        <td height="30" colspan="3" class="bigtext">
                        &nbsp;货到付款：
                        <input type="text" style="width:50px" name="info[hdfk]" id="hdfk"  value="<?php if($mall['hdfk']==''){echo "是";}else{echo $mall['hdfk'];}?>" />
                        &nbsp;正规发票：<input type="text" style="width:50px" name="info[zgfp]" id="zgfp"  value="<?php if($mall['zgfp']==''){echo "是";}else{echo $mall['zgfp'];}?>" />
                        &nbsp;运费政策：<input type="text" style="width:50px" name="info[yfzc]" id="yfzc"  value="<?php if($mall['yfzc']==''){echo "是";}else{echo $mall['yfzc'];}?>"/>
                        &nbsp;网站认证：<input type="checkbox" name="info[renzheng]" id="renzheng" <?php if($mall['renzheng']=='on'){?> checked="checked"<?php }?> />                       
                        </td>
                      </tr>
                      <tr>
                        <td width="196" height="30" align="right" class="bigtext">到期时间：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[end_time]" type="text" style="width:90px" id="end_time" value="<?=$mall['end_time']?>"/>  （默认为2050-01-01）                       </td>
                       <script language="javascript" type="text/javascript">
					 date = new Date();
					 document.getElementById ("end_time").value="<?=$mall['end_time']?>";
					Calendar.setup({
						inputField     :    "end_time",
						ifFormat       :    "%Y-%m-%d",
						showsTime      :    true,
						timeFormat     :    "24"
					});
				 </script>
                      </tr>
                      <tr class="tuan">
                        <td width="196" height="30" align="right" class="bigtext">商品api规则：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[api_rule]" type="api_rule" size="20" id="des" value="<?=$mall['api_rule']?>"/> <span style="color:#999; font-size:12px">团购网站采集商品专用</span></td>
                      </tr>
                      <tr class="tuan">
                        <td width="196" height="30" align="right" class="bigtext">商品api：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[api_url]" type="api_url" size="60" id="des" value="<?=$mall['api_url']?>"/> <span style="color:#999; font-size:12px">团购网站采集商品专用</span></td>
                      </tr>
                      <tr class="tuan">
                        <td width="196" height="30" align="right" class="bigtext">城市api：</td>
                        <td height="30" colspan="3" class="bigtext">&nbsp;<input name="info[api_city]" type="text" size="60" id="api_city" value="<?=$mall['api_city']?>"/>&nbsp;&nbsp;<a style="color:#F30" href="javascript:openwinx('ajax.php?mallid=<?=$mall['id']?>&rule=<?=$mall['api_rule']?>&api_city=<?=$mall['api_city']?>','upload','450','350')">生成城市缓存</a>  <span style="color:#999; font-size:12px">团购网站采集商品专用</span></td>
                      </tr>
                      <tr>
                        <td height="30" align="right" class="bigtext">介绍：</td>
                        <td height="30" colspan="3"><textarea id="content" name="info[js]" style="width:700px;height:200px;visibility:hidden;"><?=$mall ['js']?></textarea></td>
                      </tr>
                      <tr>
                        <td height="30" align="right" class="bigtext">提交：</td>
                        <td height="30" colspan="3"><table width="455" height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="190">&nbsp;<input type="submit" value="提交" /></td>
    <td width="265"><!--<a href="http://bbs.duoduo123.com/read.php?tid=7527&ds=1&page=1&toread=1#tpc" target="_blank">成果教程</a> --><a href="http://bbs.duoduo123.com/read-htm-tid-69490.html" target="_blank">&nbsp;多麦教程</a> <a href="http://bbs.duoduo123.com/read-htm-tid-7522.html" target="_blank">亿起发教程</a> <a href="http://soft.duoduo123.com/help/V70/2011/0221/145.html" target="_blank">&nbsp;领客特教程</a></td>
  </tr>
</table></td>
                      </tr>
                    </table>
                    <input type="hidden" name="info[id]" id="id" value="<?=$id?>"  />
                  </form>
                  </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>
<?php mysql_close();?>